
#include <math/vector.h>
#include <gfx/renderenvironment.h>
#include <scene/billboardanimator.h>
#include <scene/entitynode.h>

ceBillboardAnimator::ceBillboardAnimator()
  : _dof (DOF_Z)
{
}

void ceBillboardAnimator::SetDegreeOfFreedom(DegreeOfFreedom dof)
{
  _dof = dof;
}

ceBillboardAnimator::DegreeOfFreedom ceBillboardAnimator::GetDegreeOfFreedom() const
{
  return _dof;
}

void ceBillboardAnimator::Animate(ceNode *node, ceRenderEnvironment &env)
{
  ceVector3f p = env.CameraLocationGlobal;
  ceVector3f u = ceVector3f (0, 0, 1);
  switch (_dof)
    {
    case DOF_Z:
      // correct the position, the look at position must be in the same height
      p.z = node->GetGlobalTranslation().z;
      break;
    case DOF_XZ:
      break;
    }
  node->GlobalLookAt(p, u);
}
